home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Libraries
/
Fab Libraries
/
Conversions.a
< prev
next >
Wrap
Text File
|
1994-01-03
|
2KB
|
179 lines
* asm-optimized routines for numerical conversions
CASE ON
* STRING PASCAL
* INCLUDE 'Notification.a'
* INCLUDE 'SysEqu.a'
* INCLUDE 'TimeEqu.a'
* INCLUDE 'Traps.a'
* INCLUDE 'Processes.a'
SEG 'Main'
* pascal
SHORTTOHEXTEXT PROC EXPORT
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.W (SP)+,D0
MOVEQ #3,D2
@loop
ROL.W #4,D0
MOVE.B D0,D1
ANDI.B #15,D1
ADDI.B #48,D1
CMPI.B #57,D1
BLS.S @oltre
ADDQ.B #7,D1
@oltre
MOVE.B D1,(A0)+
DBF D2,@loop
MOVE.L A0,(SP)
JMP (A1)
ENDP
* pascal
SHORTTOHEXSTRING PROC EXPORT
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.W (SP)+,D0
MOVE.B #4,(A0)+
MOVEQ #3,D2
@loop
ROL.W #4,D0
MOVE.B D0,D1
ANDI.B #15,D1
ADDI.B #48,D1
CMPI.B #57,D1
BLS.S @oltre
ADDQ.B #7,D1
@oltre
MOVE.B D1,(A0)+
DBF D2,@loop
JMP (A1)
ENDP
* pascal
SHORTTOOCTSTRING PROC EXPORT
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.W (SP)+,D0
MOVE.B #6,(A0)+
ROL.W #1,D0
MOVE.B D0,D1
ANDI.B #1,D1
ADDI.B #48,D1
MOVE.B D1,(A0)+
MOVEQ #4,D2
@loop
ROL.W #3,D0
MOVE.B D0,D1
ANDI.B #7,D1
ADDI.B #48,D1
MOVE.B D1,(A0)+
DBF D2,@loop
JMP (A1)
ENDP
* pascal
SHORTTOBINSTRING PROC EXPORT
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.W (SP)+,D0
MOVE.B #16,(A0)+
MOVEQ #15,D2
@loop
MOVEQ #48,D1
TST.W D0
BPL.S @dopo
ADDQ.B #1,D1
@dopo
MOVE.B D1,(A0)+
LSL.W #1,D0
DBF D2,@loop
JMP (A1)
ENDP
* pascal
HEXSTRINGTOSHORT PROC EXPORT
MOVE.L (SP)+,D0
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.L D0,-(SP)
MOVEQ #0,D0
MOVEQ #0,D2
MOVE.B (A0)+,D2
SUBQ.B #1,D2
ASL.W #2,D2
@loop
MOVEQ #0,D1
MOVE.B (A0)+,D1
SUBI.B #48,D1
CMPI.B #9,D1
BLS.S @vabene
SUBQ.B #7,D1
@vabene
ASL.W D2,D1
ADD.W D1,D0
SUBQ.B #4,D2
BGE.S @loop
MOVE.W D0,(A1)
RTS
ENDP
* pascal
OCTSTRINGTOSHORT PROC EXPORT
MOVE.L (SP)+,D0
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.L D0,-(SP)
MOVEQ #0,D0
MOVEQ #0,D2
MOVE.B (A0)+,D2
SUBQ.B #1,D2
MOVE.W D2,D1
ADD.W D2,D2
ADD.W D1,D2
@loop
MOVEQ #0,D1
MOVE.B (A0)+,D1
SUBI.B #48,D1
ASL.W D2,D1
ADD.W D1,D0
SUBQ.B #3,D2
BGE.S @loop
MOVE.W D0,(A1)
RTS
ENDP
* pascal
BINSTRINGTOSHORT PROC EXPORT
MOVE.L (SP)+,D0
MOVEA.L (SP)+,A1
MOVEA.L (SP)+,A0
MOVE.L D0,-(SP)
MOVEQ #0,D0
MOVEQ #0,D2
MOVE.B (A0)+,D2
SUBQ.B #1,D2
@loop
MOVEQ #0,D1
MOVE.B (A0)+,D1
SUBI.B #48,D1
ASL.W D2,D1
OR.W D1,D0
DBF D2,@loop
MOVE.W D0,(A1)
RTS
ENDP
END